import Koa from 'koa';
import Router from 'koa-router';
import bodyParser from 'koa-bodyparser';

const koa=new Koa();
const router= new Router();


router.get('/user/:id?',async(ctx,next)=>{
    let id=ctx.params.id;
    let name=ctx.query.body;
    ctx.body=id+name;
})

koa.use(bodyParser());

router.post('/log/:id?',async(ctx,next)=>{
    let id=ctx.request.body;
    console.log(id);
    ctx.body="修改页面";
})

router.put('/user',async (ctx,next)=>{
    let name=ctx.request.body;
    console.log(name);
    ctx.body="新增页面";
});

router.delete('/del',(ctx,next)=>{
    let del=ctx.request.body;
    console.log(del);
    ctx.body="删除页面";
})


koa.use(router.routes());

koa.listen(8080,()=>{
    console.log('服务器运行在http://localhost:8080');
})